import { defHttp } from "@/utils/http";

// BPM 流程分类 VO
export interface CategoryVO {
	id: number; // 分类编号
	name: string; // 分类名
	code: string; // 分类标志
	status: number; // 分类状态
	sort: number; // 分类排序
}

// BPM 流程分类 API
export const CategoryApi = {
	// 查询流程分类分页
	getCategoryPage: async (params: any) => {
		return await defHttp.get({ url: `/bpm/category/page`, params });
	},

	// 查询流程分类列表
	getCategorySimpleList: async () => {
		return await defHttp.get({ url: `/bpm/category/simple-list` });
	},

	// 查询流程分类详情
	getCategory: async (id: number) => {
		return await defHttp.get({ url: `/bpm/category/get?id=` + id });
	},

	// 新增流程分类
	createCategory: async (data: CategoryVO) => {
		return await defHttp.post({ url: `/bpm/category/create`, data });
	},

	// 修改流程分类
	updateCategory: async (data: CategoryVO) => {
		return await defHttp.put({ url: `/bpm/category/update`, data });
	},

	// 批量修改流程分类的排序
	updateCategorySortBatch: async (ids: number[]) => {
		return await defHttp.put({
			url: `/bpm/category/update-sort-batch`,
			params: {
				ids: ids.join(",")
			}
		});
	},

	// 删除流程分类
	deleteCategory: async (id: number) => {
		return await defHttp.delete({ url: `/bpm/category/delete?id=` + id });
	}
};
